// 构建消费者
const {initConnection} = require('../util/initMq')

async function consumerDLX() {
    const exchane = 'dram_dxl';
    const queueDLX = 'testDLXQueueTwo';
    const routingKeyDLX = 'testRoutingKeyTwo';


    // 1. 创建链接对象
    const connection = await initConnection();
    const ch = await connection.createChannel();
    await ch.assertExchange(exchane, 'direct', { durable: true });
    const queueResult = await ch.assertQueue(queueDLX, {
        exclusive: false,
    });
    await ch.bindQueue(queueResult.queue, exchane, routingKeyDLX);
    await ch.consume(queueResult.queue, msg => {
        console.log('consumer msg：', msg.content.toString());
    }, { noAck: true });
}

consumerDLX();
